package com.feri.findlife.service.impl;

import com.feri.findlife.dao.CircleDao;
import com.feri.findlife.dto.PageDto;
import com.feri.findlife.pojo.Circle;
import com.feri.findlife.service.intf.CircleService;
import com.feri.findlife.vo.R;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: FindLife
 * @description:
 * @author: Feri
 * @create: 2020-12-21 15:08
 */
@Service
public class CircleServiceImpl implements CircleService {
    @Autowired
    private CircleDao dao;
    @Override
    public R save(Circle circle) {
        if(dao.add(circle)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }
    @Override
    public R all() {
        return R.ok(dao.all());
    }

    @Override
    public R allTop() {
        return R.ok(dao.allTop());
    }


    @Override
    public R selectByPage(PageDto dto) {
        //
        String m=dto.getMsg();
        if(m!=null && m.length()>0){
            m="%"+m+"%";
        }
        //
        PageHelper.startPage(dto.getPage(),dto.getSize());
        //
        return R.ok(dao.selectByTitle(m));
    }

}
